<?php require_once('../Connections/locale.php'); ?>
<?php
mysql_select_db($database_locale, $locale);
$query_province = "SELECT * FROM province, regioni where province.id_regione= regioni.id_regione";
$province = mysql_query($query_province, $locale) or die(mysql_error());
$row_province = mysql_fetch_assoc($province);
$totalRows_province = mysql_num_rows($province);

mysql_select_db($database_locale, $locale);

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
<link href="../style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table border="1" id="datatable">
  <tr>
    <td>ID</td>
    <td>Sigla Provincia</td>
    <td>Nome Provincia</td>
    <td>Regione</td>
	 <td><a href="inserisci_provincia.php"><img src="../images/page.gif" alt="Nuovo Elemento" width="18" height="18" border="0" /></a></td>
    <td></td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_province['id_provincia']; ?></td>
      <td><?php echo $row_province['sigla_provincia']; ?></td>
      <td><?php echo $row_province['nome_provincia']; ?></td>
      <td><?php echo $row_province['nome_regione']; ?></td>
	  	 <td><a href="modifica_provincia.php?id_provincia=<?php echo $row_province['id_provincia']; ?>"><img src="../images/modifica.png" alt="Modifica" width="16" height="16" border="0" /></a></td>
    <td><?php 
	
	
	$query_legami_citta = "SELECT * FROM citta WHERE id_provincia =".$row_province['id_provincia'];
	$legami_citta = mysql_query($query_legami_citta, $locale) or die(mysql_error());
	$row_legami_citta = mysql_fetch_assoc($legami_citta);
	$totalRows_legami_citta = mysql_num_rows($legami_citta);
	
	
	if ($totalRows_legami_citta == 0) { // Show if recordset empty ?>
        <img src="../images/elimina.png" alt="Elimina" width="16" height="16" />
        <?php } // Show if recordset empty ?></td>
    </tr>
    <?php } while ($row_province = mysql_fetch_assoc($province)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($province);

mysql_free_result($legami_citta);
?>
